<template>
	<el-row>
			<el-col :span="13">
				<div class="grid-content logo-title">
					<router-link to="/" style="color:#ffffff;"><i @click="refresh" style="font-size:28pt;" class="iconfont icon-datubiao-cloud-"></i></router-link>
					<span>全科医生临床诊疗辅助系统</span>
				</div>
			</el-col>
			<el-col :span="5" class="grid-content menu">
				<label>【{{curUser.stationName}}-{{curUser.userName}}】</label>
			</el-col>
			<el-col :span="6">
				<div class="grid-content menu">
					<el-row>
						<el-col :span="3">
							<a href="javascript:void(0)" @click="handleSave">暂存</a>
						</el-col>
						<el-col :span="3">
							<a href="javascript:void(0)" @click="handleFile">归档</a>
						</el-col>
						<el-col :span="3">
							<router-link to="/" target="_blank">新增</router-link>
						</el-col>
						<el-col :span="3">
							<a href="javascript:void(0)" @click="kaiDrug">取药</a>
						</el-col>
						<el-col :span="3">
							<a href="javascript:void(0)" @click="kaiExam">检查</a>
						</el-col>
						<el-col :span="4">
							<el-dropdown trigger="click">
						      	<span style="color: #ffffff;font-size:12pt;">
						        	管理<i class="el-icon-arrow-down el-icon--right"></i>
						      	</span>
						      	<el-dropdown-menu slot="dropdown" class="dropMenu">
						        	<!-- <el-dropdown-item>
						        		<router-link to="/search" target="_blank">查找</router-link>
						        	</el-dropdown-item> -->
						        	<el-dropdown-item>
						        		<router-link to="/statistic" target="_blank">统计</router-link>
						        	</el-dropdown-item>
						        	<el-dropdown-item>
						        		<router-link to="/manage" target="_blank">管理</router-link>
						        	</el-dropdown-item>
						    	</el-dropdown-menu>
						    </el-dropdown>
						</el-col>
						<el-col :span="3">
							<a href="javascript:void(0)" @click="loginOut">退出</a>
						</el-col>
					</el-row>
				</div>
			</el-col>
		</el-row>
</template>
<script type="text/javascript">
export default{
	name:'Top',
	data(){
		return{
			curUser:''
		}
	},
	computed:{
		saveFlag(){
			return this.$store.state.saveFlag;
		}
	},
	methods:{
		loginOut:function(){
			if (confirm("确定退出当前系统？")) {
				localStorage.clear();
				this.$router.push({path:'/login'});
			}
		},
		handleSave:function(){
			if (this.saveFlag.flag) {
				this.$store.commit({
					type:"setSaveFlag",
					saveFlag: {
						flag:false,
						type:"SAVE_TEMP"
					}
				});
			}
		},
		handleFile:function(){
			if (this.saveFlag.flag) {
				this.$store.commit({
					type:"setSaveFlag",
					saveFlag: {
						flag:false,
						type:"SAVE_FILE"
					}
				});
			}
		},
		refresh:function(){
			window.location.reload();
		},
		kaiExam:function(){
			this.$store.commit({
							type: "setKaiExam",
							kaiExam: {
								timeStamp:new Date().getTime()
							}
					});
		},
		kaiDrug:function(){
			this.$store.commit({
							type: "setKaiDrug",
							kaiDrug: {
								timeStamp:new Date().getTime()
							}
					});
		}
	},
	created:function(){
		var curUser =  JSON.parse(localStorage.getItem('curUser'));
		this.curUser = curUser;
		this.$store.commit({
				type:"setCurUser",
				curUser: curUser
			});

	}
}
</script>
<style type="text/css" scoped>
.el-row {
	background-color: green;
	color: white;
}
.logo-title{
	text-align: left;
	font-size: 28px;
	font-weight: bolder;
	line-height: 50px;
	letter-spacing: 10px;
}
.grid-content {
	min-height: 50px;
	line-height: 50px;
}
.menu{
	text-align: right;
	line-height: 35px;
}
.menu a:VISITED{
	color: white;
	text-decoration: none;
}
.menu a:LINK{
	color: white;
	text-decoration: none;
}
.menu a:HOVER{
	color: #ff0000;
	font-weight: bolder;
}
.dropMenu a:VISITED{
	color: #000000;
	text-decoration: none;
}
.dropMenu a:LINK{
	color: #000000;
	text-decoration: none;
}
.dropMenu a:HOVER{
	color: #ff0000;
	font-weight: bolder;
}
</style>